using System;
using System.Collections.Generic;
using System.Text;
using MyHotel_DTO;
using System.Data;
using MyHotel_Common;
using System.Data.SqlClient;


namespace MyHotel_DAO
{
    public class TinhTrangDAO : DAO
    {
        protected override object createObjectFromDatarow(DataRow row)
        {
            TinhTrang tinhtrang = new TinhTrang();
            tinhtrang.Matinhtrang = Convert.ToInt32(row["MaTinhTrang"]);
            tinhtrang.Tentinhtrang = row["Tentinhtrang"].ToString();
            return tinhtrang;
        }
        
        public List<TinhTrang> getList()
        {
            string procName = "SP_GETLIST_TINHTRANG";
            DataTable dt = DataProvider.executeStoreProcedureQuery(procName);
            return getListFromDataTable<TinhTrang>(dt);
        }
 
        public bool themTinhTrang(TinhTrang tinhtrang)
        {
            string nameProc = "SP_THEM_TAIKHOAN";
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MATINHTRANG", tinhtrang.Matinhtrang);
            para[1] = new SqlParameter("@TENTINHTRANG", tinhtrang.Tentinhtrang);
            
            return (DataProvider.executeStoreProcedureNonQuery(nameProc, para) == 1);

        }
    }
}
